package cn.com.cennavi.bean;

import java.io.Serializable;

public class HighPrecisionCombineDirTraffic implements Serializable {

	private static final long serialVersionUID = 1L;

	/**
	 * 字段说明： 一条记录按照","分隔 1、路口id： 要与路口id和坐标点对应表中的路口id一致 2、分歧点坐标点：经纬度按照"|"分隔
	 * 3、角度：与正北的夹角 4、是否左右出/入：两位标示，00表示左出，10表示右出，01表示左入，11表示右入
	 * 5、直道路口前长度1_直道路口前速度1|直道路口前长度2_直道路口前速度2： 长度和速度组成一段路，长度和速度按照"_"分隔，每段路按照"|"分隔
	 * 6、直道路口后长度1_直道路口前速度1|直道路口前长度2_直道路口前速度2： 长度和速度组成一段路，长度和速度按照"_"分隔，每段路按照"|"分隔
	 * 7、弯道路口前长度1_弯道路口前速度1|弯道路口前长度2_弯道路口前速度2： 长度和速度组成一段路，长度和速度按照"_"分隔，每段路按照"|"分隔
	 * 8、弯道路口后长度1_弯道路口前速度1|弯道路口前长度2_弯道路口前速度2： 长度和速度组成一段路，长度和速度按照"_"分隔，每段路按照"|"分隔
	 * 9、直行道路的总长度 10、转弯道路的总长度 例子：
	 * 65543,116.23223|39.12323,-180,01,80_12|70_67,80_21|34_20|30_10,50_10|
	 * 40_23,80_21|34_20|30_10,404,404
	 **/
	public String roadId;

	public double lon;

	public double lat;

	public double angle;

	public String direction;

	/** 直行分歧点前link长度、速度序列 **/
	public String bef_straight_linkLength_speed_Arr;

	/** 直行分歧点后link长度、速度序列 **/
	public String aft_straight_linkLength_speed_Arr;

	/** 进或者出分歧点前link长度、速度序列 **/
	public String bef_bent_linkLength_speed_Arr;

	/** 进或者出分歧点后link长度、速度序列 **/
	public String aft_bent_linkLength_speed_Arr;
	public String timeStamp_5min;
	public int straight_totalLength;
	public int bent_totalLength;
	public int dateTime;
	public int straight_difPoint_befLength;
	public int straight_difPoint_aftLength;
	public int bent_difPoint_befLength;
	public int bent_difPoint_aftLength;
	public String carIdTimeSeq;
	public int roadClass;

	public String toString() {
		StringBuffer sb = new StringBuffer();
		sb.append(this.roadId);
		sb.append(",");
		sb.append(this.lon + "|" + this.lat);
		sb.append(",");
		sb.append(this.angle);
		sb.append(",");
		sb.append(this.direction);
		sb.append(",");
		sb.append(this.bef_straight_linkLength_speed_Arr);
		sb.append(",");
		sb.append(this.aft_straight_linkLength_speed_Arr);
		sb.append(",");
		sb.append(this.bef_bent_linkLength_speed_Arr);
		sb.append(",");
		sb.append(this.aft_bent_linkLength_speed_Arr);
		sb.append(",");
		sb.append(this.timeStamp_5min);
		sb.append(",");
		sb.append(this.straight_totalLength);
		sb.append(",");
		sb.append(this.bent_totalLength);
		sb.append(",");
		sb.append(straight_difPoint_befLength);
		sb.append(",");
		sb.append(straight_difPoint_aftLength);
		sb.append(",");
		sb.append(bent_difPoint_befLength);
		sb.append(",");
		sb.append(bent_difPoint_aftLength);
		sb.append(",");
		sb.append(carIdTimeSeq);
		sb.append(",");
		sb.append(roadClass);
		return sb.toString();
	}

	public String toString1() {
		StringBuffer sb = new StringBuffer();
		sb.append(this.roadId);
		sb.append(",");
		sb.append(this.lon + "|" + this.lat);
		sb.append(",");
		sb.append(this.angle);
		sb.append(",");
		sb.append(this.direction);
		sb.append(",");
		sb.append(this.bef_straight_linkLength_speed_Arr);
		sb.append(",");
		sb.append(this.aft_straight_linkLength_speed_Arr);
		sb.append(",");
		sb.append(this.bef_bent_linkLength_speed_Arr);
		sb.append(",");
		sb.append(this.aft_bent_linkLength_speed_Arr);
		sb.append(",");
		sb.append(this.timeStamp_5min);
		sb.append(",");
		sb.append(this.straight_totalLength);
		sb.append(",");
		sb.append(this.bent_totalLength);
		sb.append(",");
		sb.append(straight_difPoint_befLength);
		sb.append(",");
		sb.append(straight_difPoint_aftLength);
		sb.append(",");
		sb.append(bent_difPoint_befLength);
		sb.append(",");
		sb.append(bent_difPoint_aftLength);
		sb.append(",");
		sb.append(roadClass);
		return sb.toString();
	}

	public String toString2() {
		StringBuffer sb = new StringBuffer();
		sb.append(this.roadId);
		sb.append(",");
		sb.append(this.lon + "|" + this.lat);
		sb.append(",");
		sb.append(this.angle);
		sb.append(",");
		sb.append(this.direction);
		sb.append(",");
		sb.append(this.bef_straight_linkLength_speed_Arr);
		sb.append(",");
		sb.append(this.aft_straight_linkLength_speed_Arr);
		sb.append(",");
		sb.append(this.bef_bent_linkLength_speed_Arr);
		sb.append(",");
		sb.append(this.aft_bent_linkLength_speed_Arr);
		sb.append(",");
		sb.append(this.timeStamp_5min);
		sb.append(",");
		sb.append(this.straight_totalLength);
		sb.append(",");
		sb.append(this.bent_totalLength);
		sb.append(",");
		sb.append(straight_difPoint_befLength);
		sb.append(",");
		sb.append(straight_difPoint_aftLength);
		sb.append(",");
		sb.append(bent_difPoint_befLength);
		sb.append(",");
		sb.append(bent_difPoint_aftLength);
		return sb.toString();
	}

	public HighPrecisionCombineDirTraffic parseLine(String outPutDataString) {
		String[] arr = outPutDataString.split(",");
		if (arr.length >= 17) {
			HighPrecisionCombineDirTraffic opd = new HighPrecisionCombineDirTraffic();
			opd.roadId = arr[0];
			String[] lonlat = arr[1].split("\\|");
			opd.lon = Double.parseDouble(lonlat[0]);
			opd.lat = Double.parseDouble(lonlat[1]);
			opd.angle = Double.parseDouble(arr[2]);
			opd.direction = arr[3];
			opd.bef_straight_linkLength_speed_Arr = arr[4];
			opd.aft_straight_linkLength_speed_Arr = arr[5];
			opd.bef_bent_linkLength_speed_Arr = arr[6];
			opd.aft_bent_linkLength_speed_Arr = arr[7];
			opd.timeStamp_5min = arr[8];
			opd.straight_totalLength = Integer.parseInt(arr[9]);
			opd.bent_totalLength = Integer.parseInt(arr[10]);
			opd.straight_difPoint_befLength = Integer.parseInt(arr[11]);
			opd.straight_difPoint_aftLength = Integer.parseInt(arr[12]);
			opd.bent_difPoint_befLength = Integer.parseInt(arr[13]);
			opd.bent_difPoint_aftLength = Integer.parseInt(arr[14]);
			opd.carIdTimeSeq = arr[15];
			opd.roadClass = Integer.parseInt(arr[16]);
			return opd;
		}
		return null;

	}

	private static String timeToString(int length, int number) {
		String f = "%0" + length + "d";
		return String.format(f, number);
	}

	public static void main(String[] args) {
		System.out.println(timeToString(4, 1));
	}
}
